﻿
InfoWindow = {};
InfoWindow.selectPlateNo="";
InfoWindow.setPlateNo = function(plateNo){
	this.selectPlateNo = plateNo;
}

//查看车辆信息
InfoWindow.viewVehicle = function(entityId){
    InfoWindow.open(globalConfig.webPath + "/vehicle/view.action?entityId=" + entityId, 750, 540,"车辆信息");
}


//查看车辆只读信息
InfoWindow.viewVehicleInfo = function(entityId){
    InfoWindow.open(globalConfig.webPath + "/vehicle/viewInfo.action?vehicleId=" + entityId, 750, 540,"车辆信息");
}

//查看终端信息
InfoWindow.viewTerminal = function(entityId){
    InfoWindow.openChildWindow(globalConfig.webPath + "/terminalInfo/view.action?entityId=" + entityId, 680, 340,"终端信息");
}


//查看角色
InfoWindow.viewRole = 	function(EntityId){
    InfoWindow.open(globalConfig.webPath + "/role/view.action?entityId=" + EntityId, 590, 580);
}

//查看部门信息
InfoWindow.viewDep = 	function(EntityId){
    InfoWindow.open(globalConfig.webPath + "/dep/view.action?entityId=" + EntityId, 650, 400);
}

//用户信息
InfoWindow.viewUser = 	function(EntityId){
    InfoWindow.open(globalConfig.webPath + "/user/view.action?entityId=" + EntityId, 690, 520);
}


//编辑路线窗口
InfoWindow.viewRoute = 	function(EntityId){
    InfoWindow.open(globalConfig.webPath + "/mapArea/viewRoute.action?entityId=" + EntityId, 620, 370);
}

//查看线段拐点编辑窗口
InfoWindow.viewSegment = 	function(EntityId){
    InfoWindow.openChildWindow(globalConfig.webPath + "/mapArea/viewLineSegment.action?input=true&entityId=" + EntityId, 720, 420);
}

//查看线段分段限速点编辑窗口
InfoWindow.viewRouteSegment = 	function(EntityId){
    InfoWindow.openChildWindow(globalConfig.webPath + "/mapArea/viewRouteSegment.action?input=true&entityId=" + EntityId, 720, 220);
}

//编辑权限信息
InfoWindow.editFuncInfo = function(EntityId){
    InfoWindow.open(globalConfig.webPath + "/functionModel/view.action?entityId=" + EntityId, 670, 290,"权限信息");
}


//编辑车辆状态地图标
InfoWindow.editVehicleStateIcon = 	function(EntityId){
    InfoWindow.open(globalConfig.webPath + "/vehicleStateIconConfig/viewConfig.action?entityId=" + EntityId, 720, 520,"车辆状态地图标信息");
}

//编辑驾驶员信息
InfoWindow.editDriverInfo = 	function(EntityId){
    InfoWindow.open(globalConfig.webPath + "/driverInfo/view.action?entityId=" + EntityId, 720, 520,"驾驶员信息");
}

//查看驾驶员信息
InfoWindow.viewDriverInfo = 	function(driverId){
    InfoWindow.open(globalConfig.webPath + "/vehicle/viewDriverInfo.action?driverId=" + driverId, 720, 520);
}

//查看报警信息
InfoWindow.viewAlarm = 	function(alarmId){
    InfoWindow.open(globalConfig.webPath + "/alarm/view.action?alarmId=" + alarmId, 400, 380,"报警处理");
}

//查看围栏信息
InfoWindow.viewMapArea = function (EntityId){
    InfoWindow.open(globalConfig.webPath + "/data/viewArea.action?entityId=" + EntityId, 720,370);
}

//查看未绑定车辆信息
InfoWindow.viewUnbindVehicle = function (EntityId){
    InfoWindow.open(globalConfig.webPath + "/data/getUnbindVehicle.action?areaId=" + EntityId, 850,390);
}


//查看业户信息
InfoWindow.viewMember = function (EntityId){
    InfoWindow.open(globalConfig.webPath + "/memberInfo/view.action?entityId=" + EntityId, 700,390);
}

//查看基础数据编辑信息
InfoWindow.viewBasicData = function (EntityId){
    InfoWindow.open(globalConfig.webPath + "/basicData/view.action?entityId=" + EntityId, 500,300);
}
//查看信息点播菜单编辑信息
InfoWindow.viewInfoMenu = function (EntityId){
    InfoWindow.open(globalConfig.webPath + "/system/viewInfoMenu.action?entityId=" + EntityId, 500,300);
}

//查看给终端发布的信息
InfoWindow.viewInformation = function (EntityId){
    InfoWindow.open(globalConfig.webPath + "/basicData/viewInformation.action?entityId=" + EntityId, 500,300);
}

//查看图片信息备注描述
InfoWindow.viewMediaItemRemark = function (EntityId){
    InfoWindow.open(globalConfig.webPath + "/mediaItem/view.action?entityId=" + EntityId, 500,300);
}

//查看附件信息
InfoWindow.viewAdasAlarmAttachment = function (url){
    InfoWindow.openChildWindow(url, 800,600);
}
//查看图片信息备注描述
InfoWindow.viewAdasAlarmAttachmentList = function (path,alarmId){
	InfoWindow.open(globalConfig.webPath + "/adasAlarm/viewAttachmentList.action?entityId=" + EntityId, 800,300);
}



//打开服务器录像文件播放页面
InfoWindow.viewVideoResourcePlayer = function (strResourceIds){
    InfoWindow.openChildWindow(globalConfig.webPath + "/videoPlayBack/viewVideoResourcePlayer.action?strResourceIds=" + strResourceIds, 685,600);
}


//查看ftp资源文件
InfoWindow.viewFtpFileList = function (vehicleId){
    InfoWindow.openChildWindow(globalConfig.webPath + "/report/viewFtpFileList.action?vehicleId=" + vehicleId, 900,400);
}


InfoWindow.newBasicData= function (parentCode){
    InfoWindow.open(globalConfig.webPath + "/basicData/view.action?parent=" + parentCode, 500,300);
}
/**
 * 打开选择车辆的窗口
 */
InfoWindow.selectVehicle = function()
{
	var url = globalConfig.webPath+"/vehicle/selectVehicle.action";
	InfoWindow.openChildWindow(url, 765,350,"选择车辆");
}

InfoWindow.selectDep = function()
{
	var url = globalConfig.webPath+"/dep/viewSelectDep.action";
	InfoWindow.openChildWindow(url, 565,350,"选择部门");
}

//查看报警设置信息
InfoWindow.editAlarmConfig = function (EntityId){
    InfoWindow.open(globalConfig.webPath + "/alarmConfig/viewConfig.action?entityId=" + EntityId, 720,420);
}

InfoWindow.viewRealTimeVideo = function(vehicleId, plateNo, simNo)
{
    var alarmWindowTitle = plateNo ;
    var channelArray = [1,2,3,4];
    var win = typeof(AlarmVideoWindow) == "undefined"  ?  window.parent.AlarmVideoWindow :AlarmVideoWindow;
    win.viewRealTimeVideo(vehicleId, plateNo, simNo,alarmWindowTitle, channelArray);
    //InfoWindow.open(globalConfig.webPath + "/videoCommand/viewRealTimeVideo.action?vehicleId=" + vehicleId, 720,420,"视频监控窗口");
}

/**
 * 打开监听页面
 * @param vehicleId
 * @param autoStart
 */
InfoWindow.viewListenVideoTerminal = function(simNo, channelId, autoStartType)
{
	//autoStart = autoStart == true ? true :false;
    InfoWindow.open(globalConfig.webPath + "/videoCommand/viewListenVideoTerminal.action?simNo=" + simNo
        + "&channelId=" + channelId
		+ "&autoStartType=" + autoStartType, 720,420);
}

/**
 * 打开对讲页面
 * @param vehicleId
 * @param autoStart
 */
InfoWindow.viewTalkVideoTerminal = function(simNo, channelId,autoStartType)
{
    //autoStart = autoStart == true ? true :false;
    InfoWindow.open(globalConfig.webPath + "/videoCommand/viewTalkVideoTerminal.action?simNo=" + simNo
        + "&channelId=" + channelId
		+ "&autoStartType=" + autoStartType, 720,420);
}

/**
 * 打开发送文本窗口
 * @param vehicleId 车辆id
 * @param title 标题
 * @param url 请求地址，例 "/sendText.action"
 */
InfoWindow.viewSendTextWindow = function( vehicleId,title, url){
	var commandPath = globalConfig.webPath;
	if(url != null)
	{
		url = commandPath + url+ "?vehicleId="+vehicleId;
	}
	InfoWindow.openChildWindow(url,620, 300,title);
}



//查看用户选项信息
InfoWindow.editUserPreference = function (EntityId){
    InfoWindow.open(globalConfig.webPath + "/user/viewPreference.action", 480,280);
}

//当点击命令按钮或菜单时，弹出命令发送窗口
InfoWindow.openCommandWindow = function(command, vehicleId,title,icon, url)
{
	
	var commandPath = globalConfig.webPath;
	if(url != null)
        url = commandPath + url+ "?vehicleId="+vehicleId;
	//var title = "终端命令";
	//alert(command+","+ vehicleId);
     if(command=="CALL_NOW")
	{
		 //点名
		//var url = commandPath + "/command/callTerminal.action";
        //url += "?input=true&vehicleId="+vehicleId;
		InfoWindow.open(url, 320, 115, title);
	}else if(command == "TERMINAL_MENU")
	{
		//信息点播菜单设置
		//var url = commandPath + "/user/viewTerminalMenu.action";
        //url += "?input=true&vehicleId="+vehicleId;
		InfoWindow.open(url, 520, 400, title);
	}else if(command == "TERMINAL_CONFIG")
	{
		//终端参数配置和查询
		//var url = commandPath + "/command/terminalParamTemplate.action";
        //url += "?input=true&vehicleId="+vehicleId;
		InfoWindow.open(url, 720, 500, title);
	}else if(command == "TERMINAL_TEXT")
	{
		//文本信息下发 
		//var url = commandPath + "/command/sendText.action";
        //url += "?input=true&vehicleId="+vehicleId;
		InfoWindow.open(url, 620, 300, title);
	}else if(command == "LISTEN_TERMINAL")
	{
		//发送监听命令
		//var url = commandPath + "/command/listenTerminal.action";
        //url += "?input=true&vehicleId="+vehicleId;
		InfoWindow.open(url, 480, 220, title);
	}else if(command == "TERMINAL_EVENT")
	{
		//终端事件
		//var url = commandPath + "/command/eventConfig.action";
       // url += "?input=true&vehicleId="+vehicleId;
		InfoWindow.open(url, 520, 400, title);
	}else if(command == "OVER_SPEED_CONFIG")
	{
		//终端超速设置
		//var url = commandPath + "/command/overSpeedConfig.action";
        //url += "?input=true&vehicleId="+vehicleId;
		InfoWindow.open(url, 520, 280, title);
	}else if(command == "TIRED_CONFIG")
	{
		//终端疲劳驾驶设置
		//var url = commandPath + "/command/tiredConfig.action";
        //url += "?input=true&vehicleId="+vehicleId;
		InfoWindow.open(url, 520, 320, title);
	}else if(command == "SEND_INFORMATION")
	{
		//信息服务下发
		//var url = commandPath + "/command/sendInformation.action";
        //url += "?input=true&vehicleId="+vehicleId;
		InfoWindow.open(url, 520, 350, title);
	}else if(command == "MEDIA_UPLOAD")
	{
		//多媒体上传
		//var url = commandPath + "/command/mediaUpload.action";
        //url += "?input=true&vehicleId="+vehicleId;
		InfoWindow.open(url, 520, 400, title);
	}else if(command == "MEDIA_SEARCH")
	{
		//多媒体检索
		//var url = commandPath + "/command/mediaSearch.action";
        //url += "?input=true&vehicleId="+vehicleId;
		InfoWindow.open(url, 820, 500, title);
	}else if(command == "AUDIO_RECORDER")
	{
		//录音
		//var url = commandPath + "/command/audioRecorder.action";
        //url += "?input=true&vehicleId="+vehicleId;
		InfoWindow.open(url, 520, 320, title);
	}else if(command == "PHONE_BOOK")
	{
		//设置电话本
		//var url = commandPath + "/command/phoneBook.action";
        //url += "?input=true&vehicleId="+vehicleId;
		InfoWindow.open(url, 820, 400, title);
	}else if(command == "TAKE_PICTURE")
	{
		//拍照
		//var url = commandPath + "/command/takePicture.action";
        //url += "?input=true&vehicleId="+vehicleId;
		InfoWindow.open(url, 600, 520, title);
	}else if(command == "SEND_QUESTION")
	{
		//提问下发
		//var url = commandPath + "/command/sendQuestion.action";
        //url += "?input=true&vehicleId="+vehicleId;
		InfoWindow.open(url, 520, 400, title);
	}else if(command == "TEMP_TRACK")
	{
		//临时位置跟踪
		//var url = commandPath + "/command/tempTrack.action";
        //url += "?input=true&vehicleId="+vehicleId;
		InfoWindow.open(url, 520, 250, title);
	}else if(command == "TERMINAL_AREA")
	{
		//围栏下发窗口
		//var url = commandPath + "/command/sendMapArea.action";
        //url += "?input=true&vehicleId="+vehicleId;
		InfoWindow.open(url, 820, 550, title);
	}else if(command == "TERMINAL_ROUTE")
	{
		//配置线路
		//var url = commandPath + "/command/sendRoute.action";
        //url += "?input=true&vehicleId="+vehicleId;
		InfoWindow.open(url, 820, 550, title);
	}
	else if(command == "VEHICLE_RECORDER")
	{
		//行驶记录仪下发窗口
		//var url = commandPath + "/command/vehicleRecorder.action";
        //url += "?input=true&vehicleId="+vehicleId;
		InfoWindow.open(url, 820, 580, title);
	}else if(command == "VEHICLE_RECORDER_2012")
	{
		//行驶记录仪下发窗口
		//var url = commandPath + "/command/vehicleRecorder.action?ver=2012";
        //url += "?input=true&vehicleId="+vehicleId;
		InfoWindow.open(url, 820, 580, title);
	}else if(command == "PLATFORM_COMMAND")
	{
		//809平台命令下发窗口
		//var url = commandPath + "/command/sendPlatformCmd.action";
        //url += "?input=true&vehicleId="+vehicleId;
		InfoWindow.open(url, 520, 370, title);
	}else if(command == "WIRELESS_UPDATE")
	{
		//无线升级窗口
		//var url = commandPath + "/command/wirelessUpdate.action";
        //url += "?input=true&vehicleId="+vehicleId;
		InfoWindow.open(url, 520, 570, title);
	}else if(command == "CONTROL_TERMINAL")
	{
		//终端控制窗口
		//var url = commandPath + "/command/controlTerminal.action";
        //url += "?input=true&vehicleId="+vehicleId;
		InfoWindow.open(url, 320, 190, title);
	}else if(command == "TRANSPARENT_SEND")
	{
		//透明传输命令下发窗口
		//var url = commandPath + "/command/transparentSend.action";
        //url += "?input=true&vehicleId="+vehicleId;
		InfoWindow.open(url, 520, 350, title);
	}else if(command == "DOOR_CONTROL")
	{
		//车辆控制 门控制
		//var url = commandPath + "/command/doorControl.action";
        //url += "?input=true&vehicleId="+vehicleId;
		InfoWindow.open(url, 420, 180, title);
	}
	else if(command == "REAL_MONITOR")
	{
		console.log("start : title === " + title);
		console.log(command);
		console.log(icon);
		console.log(vehicleId);
		console.log("url ==  " + url);
		//单独监控
		 var url1 =  globalConfig.mapPath;
		 if(typeof(url1) == "undefined"){
			 url1 = globalConfig.webPath + "/map/baidu.jsp";
		 }
		 console.log("url1 ==  " + url1);
		 if (url1.indexOf("?") >= 0)
			 url1 += "&vehicleId=" + vehicleId;
		 else
			 url1 += "?vehicleId=" + vehicleId;
		if(parent && parent.addTab){
			parent.addTab(title, url1, icon);
		}else{
			addTab(title, url1, icon);
		}

		
	}else if(command == "VEHICLE_INFO")
	{
		if(url == null)
		   url = commandPath + "/vehicle/viewInfo.action?vehicleId="+vehicleId;
		  InfoWindow.open(url, 720, 450, title);
	}else if(command == "HISTORY_ROUTE")
	{ 
		title = '历史轨迹';
		addTab(title,url,icon);
		// $("body").oneTime("300ms","insertPlateNo",function()
		// {
		// 	try {
		// 		var treeManager = $.fn.zTree.getZTreeObj("vehicleTree");
		// 		var nodes = treeManager.getSelectedNodes();
		// 		if (nodes && nodes.length > 0) {
		// 			//设置历史轨迹里的车牌号
		// 			$("#routePlateNo").textbox('setValue', nodes[0].attributes["plateNo"]);
		// 		}
		// 	} catch (error) {
		// 		console.log("历史轨迹中获取选中车辆错误："+error);
		// 	}
		// });
		//HistoryRoutePanel.setPlateNo(this.selectPlateNo);
	}else if(command == "BIND_VEHICLE")
	{
		 // var url = commandPath + "/command/getBindMapArea.action";
        //url += "?input=true&vehicleId="+vehicleId;
		  InfoWindow.open(url, 820, 550, title);
	}else if(command == "VIDEO_RESOURCE_SEARCH")
	 {
         InfoWindow.open(url, 890, 500, title);
	 }else if(command == "VIDEO_DOWNLOAD")
     {
         InfoWindow.open(url, 890, 500, title);
     }else if(command == "DangerousVideo")
     {
         InfoWindow.open(url, 890, 500, title);
	 }else if(command =="LONG_DISTANCE_CONTROL")
	 {
		InfoWindow.open(url, 990, 500, title);
	 }else if(command == "VIDEO_PROPERTIES_CMD")
	 {
		InfoWindow.open(url, 990, 650, title);
	 }else if(command == "TERMINAL_PROPERTIES_CMD")
	 {
		InfoWindow.open(url, 990, 650, title);
	 }else if(command == "NEW_REALTIME_VIDEO"){
		//  console.log("右键测试菜单：test menu");
		// console.log(url);
		 addTab("新实时视频",url,"icon-camera");
	 }
	 else
	 {
         InfoWindow.open(url, 990, 500, title);
	 }
}

/**
 * 在弹出窗口的基础上继续弹出子窗口
 */
InfoWindow.openChildWindow = function(url, width, height, title, option){
	/**
	if(window.parent && window.parent.openIFrameChildWindow)
	{
		if(!title)
			title = "编辑窗口";
		window.parent.openIFrameChildWindow(url, width, height,  title);
		return;
	}*/
	
    newoption = "width = "+width+",height="+height+",left="+(window.screen.width-width)/2+",scrollbars=yes,location=no,top="+(window.screen.height-height)/2 ;
	if (option!=null || option != "")
	{
		newoption += ","+option;                                                                     
	}               
	window.open(url, "", newoption);

}

InfoWindow.open = function(url, width, height, title, option){
	
	if(window.parent && window.parent.openIFrameWindow)
	{
		if(!title)
			title = "编辑窗口";
		window.parent.openIFrameWindow(url, width, height,  title);
		return;
	}

    newoption = "width = "+width+",height="+height+",left="+(window.screen.width-width)/2+",scrollbars=yes,location=no,top="+(window.screen.height-height)/2 ;
	if (option!=null || option != "")
	{
		newoption += ","+option;                                                                     
	}               
	window.open(url, "", newoption);

}

